package com.example.scanfast.bean;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.PrimaryKey;

import java.io.Serializable;
import java.util.Objects;

/**
 * Parcelable和Serializable接口都是实现序列化和反序列化的接口,
 * 相比Serializable,Parcelable接口需要自己手动实现,效率更好，
 * 生成的序列化数据较小,效率更加高效,占用的内存比较少。
 */
//为什么要实现序列化,可以直接通过对象实现吗 区别
//实现 Serializable接口，可以实现序列化和反序列化的操作,方便对象的持久化、传输和复制。
//如果仅在单次执行过程可以不实现。
@Entity(indices = {@Index(value = "path", unique = true)})
public class FileBean implements Serializable {

    @PrimaryKey(autoGenerate = true)
    private Integer id;
    private String name;
    private String path;
    private String createTime;
    private String updateTime;
    private int icon;
    private String time;

    private String length;

    private String fileType;

    public FileBean(Integer id, String name, String path, String createTime, String updateTime, int icon, String time, String length, String fileType) {
        this.id = id;
        this.name = name;
        this.path = path;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.icon = icon;
        this.time = time;
        this.length = length;
        this.fileType = fileType;
    }



    @Ignore
    public FileBean() {
    }


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public int getIcon() {
        return icon;
    }

    public void setIcon(int icon) {
        this.icon = icon;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }







    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    public String getLength() {
        return length;
    }

    public void setLength(String length) {
        this.length = length;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FileBean fileBean = (FileBean) o;
        return icon == fileBean.icon && Objects.equals(id, fileBean.id) && Objects.equals(name, fileBean.name) && Objects.equals(path, fileBean.path) && Objects.equals(createTime, fileBean.createTime) && Objects.equals(updateTime, fileBean.updateTime) && Objects.equals(time, fileBean.time) && Objects.equals(length, fileBean.length) && Objects.equals(fileType, fileBean.fileType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, path, createTime, updateTime, icon, time, length, fileType);
    }
}
